<div>
  <table border="1" cellspacing="0">
    <tr class="tr_0">
      <th width="20" rowspan="2">总分排名</th><th rowspan="2">总分</th><th rowspan="2">ID</th>
      <th rowspan="2" width="98">投稿时间</th><th rowspan="2">标题</th><th rowspan="2" width="86">类别</th>
      <th rowspan="2" width="90">投稿人</th><th colspan="4">播放</th>
      <th colspan="3">评论</th><th colspan="3">收藏</th><th colspan="3">推荐</th><th colspan="2">弹幕</th><th colspan="2">B</th>
    </tr>
    <tr class="tr_0">
      <th>数</th><th width="20">R</th><th width="20">P</th><th width="20">比</th>
      <% (1..3).each do %><th>数</th><th width="20">R</th><th width="20">比</th><% end %>
      <% (1..2).each do %><th>数</th><th width="20">R</th><% end %>
    </tr>
<% rank_from = 30
   latest_weekly = Weekly.latest
   changqis = WeeklyResult.all_changqi(0-latest_weekly.id)
   @stats.each_with_index do |r, ind|
             tr_styles = ["tr_#{ind%2}"]
             tr_styles << "tr_gray" if r.space_fix < 1
             if r['point_rank'] &&  r['point_rank'] <= rank_from
               if changqis.include?(r.work.wid)
                 tr_styles << "tr_changqi"
                 rank_from += 1
               end
             elsif r['point_rank'].nil? && r[:hot_bangumi]
               tr_styles << "tr_hot_bangumi"
             end%>
    <tr class="<%=tr_styles.join ' '%>">
      <td><%=r['point_rank'] || '-'%></td>
      <td><b><%=r['point']%></b></td>
      <td><%=r.work.wid%></td>
      <td><%=r.work.cdate.strftime "%Y-%m-%d %H:%M" rescue nil%></td>
      <td><%=h r.work.name%></td>
      <td><%=r.work.ac_type.name%></td>
      <td><%=h r.work.author_name%></td>
      <td class="td_clicks"><%=r.clicks%></td>
      <td class="td_clicks"><%=r['click_rank']%></td>
      <td class="td_clicks"><%=r.work.part_count%></td>
      <td class="td_clicks"><%=100 * r.click_point.to_i / r['point'].to_i%></td>
      <td class="td_comm"><%=r.comments%></td>
      <td class="td_comm"><%=r['comment_rank']%></td>
      <td class="td_comm"><% unless r['point_rank'] %> <%=100 * r.comm_point_bangumi.to_i / r['point'].to_i%><% else %><%=100 * r.comm_point.to_i / r['point'].to_i%><% end %></td>
      <td class="td_stow"><%=r.stows%></td>
      <td class="td_stow"><%=r['stow_rank']%></td>
      <td class="td_stow"><% if r['point_rank'] %><%=100 * r.stow_point.to_i / r['point'].to_i%> <% end %></td>
      <td><%=r.tj%></td>
      <td><%=r['tj_rank']%></td>
      <td><% if r['point_rank'] %><%=100 * r.tj_point.to_i / r['point'].to_i%><% end %></td>
      <td><%=r.danmu%></td>
      <td><%=r['danmu_rank']%></td>
      <td><%=r.yb%></td>
      <td><%=r['yb_rank']%></td>
    </tr>
<% if r['point_rank'] && r['point_rank'] == rank_from %>
    <tr class="tr_0"><td colspan="23">- 主 - 榜 - 界 -</td></tr>
<% end %>
    <% end %>
  </table>
</div>